package edu.wpi.first.wpilibj.robot;
import edu.wpi.first.wpilibj.*;

public class GunMotor extends Motor{
    Joystick joy;
    Joystick oj;
    DriveMotor dm;
    BeltMotor bm;
    
    Keybinds kb;
    
    boolean bigGunToggle = true;
    
    PrintMotor pm;
    
    public GunMotor(Joystick joy, Joystick overrideJoy, Jaguar[] duper, DriveMotor dm, BeltMotor bm, Keybinds kb, PrintMotor pm){
        super(duper);
        this.joy = joy;
        this.dm = dm;
        this.bm = bm;
        this.oj = overrideJoy;
        this.kb = kb;
        this.pm = pm;
        
        /**
         * jaguar[0] is the trigger jag powered by the servo motor that ONLY comes on while the trigger is held
         * 
         * jaguar[1] is the big servo guy who actually shoots the ball by pushing it into that plate.
         */
    }
    public GunMotor(Joystick joy, Joystick overrideJoy, Jaguar[] duper, DriveMotor dm, BeltMotor bm, PrintMotor pm){
        this(joy, overrideJoy, duper, dm, bm, new Keybinds(), pm);
    }
    
    public void run(){
        while (true){
            if(oj.getRawButton(11)){
                bigGunToggle = false;
                pm.setText("gun OFF", 3);
            }
            if(oj.getRawButton(10)){
                bigGunToggle = true;
                pm.setText("gun ON ", 3);
            }
            
            //this.bigGunToggle = false;
            
            if (bigGunToggle) theJags[1].set(-.3);
            else theJags[1].set(0);
            while (joy.getRawButton(kb.FIRE)){
                dm.shooting = true;
                theJags[0].set(-.3);
            }
            bm.shooting = false;
            dm.shooting = false;
            theJags[0].set(0);
        }
    }
}
